Starting DOORS from VBA does not wait until login

Hello developers,

 

I use following code to start DOORS from VBA within Excel and execute a dxl script:

 

Sub CallDxlFunc()
    Dim DoorsObj As Object
    Dim Result_From_Doors As String
   
    On Error GoTo ExceptionHandling
    ' Look if we have a running instance of DOORS. If so, try to get it.
    ' If there is no running instances
    ' then create a new DOORS instance.
    Set DoorsObj = GetObject(, "DOORS.Application")
                  
ExceptionHandling:
    ' Start new instance of DOORS.
    Set DoorsObj = CreateObject("DOORS.Application")

    DoorsObj.Result = "Sent from Excel"
    DoorsObj.runFile ("L:\VSB\V_48290_1\Admin_utils\VbaComm\vba_comm_dummy.dxl")
   
    Result_From_Doors = DoorsObj.Result
    MsgBox ("Result_From_Doors = " + Result_From_Doors)
End Sub

 

The Problem is, that a Crash occurs at DoorsObj.runFile because no Login into the created and started

DOORS instance has been done. The VBA code behaves asychron.

Does anybody know how the program execution is only being continued after the Login into DOORS has been done?

 

Regards

Marco


MarcoLuk - Mon Nov 13 12:20:13 EST 2017

Re: Starting DOORS from VBA does not wait until login
Mathias Mamsch - Wed Nov 15 05:04:39 EST 2017

Would it be an option to ask for the credentials inside VB and run DOORS in "interactive batch" (i.e. start an interactive shell process, pass credentials over cmdline) instead of using COM? Regards, Mathias

Re: Starting DOORS from VBA does not wait until login
MarcoLuk - Thu Nov 16 11:40:42 EST 2017

Mathias Mamsch - Wed Nov 15 05:04:39 EST 2017

Would it be an option to ask for the credentials inside VB and run DOORS in "interactive batch" (i.e. start an interactive shell process, pass credentials over cmdline) instead of using COM? Regards, Mathias

Hello Mathias,

 

thanky for your answer.

Yes, using the Shell-VBA-function is also possible, but we do not want to have all the detailed path data of DOORS as Argument.

Meanwhile we force the user to manually start DOORS and login.

 

But we still have another Problem: Each time the function GetObject(, "DOORS.Application") crashes, even if DOORS has been started before.

Everytime I get the following VBA-error: "Laufzeitfehler '429': Objekterstellung durch Active-X-Komponente nicht möglich".

 

Used Doors Client Version: 9.6.1.9

Used Windows: Windows 7 Enterprise, Service Pack 1, 64-Bit

Used Excel Version for VBA-Code: Excel 2013

 

Does somebody have an idea, why this always Fails?

 

Regards,

Marco

Re: Starting DOORS from VBA does not wait until login
pommCannelle - Fri Nov 17 05:18:51 EST 2017

MarcoLuk - Thu Nov 16 11:40:42 EST 2017

Hello Mathias,

 

thanky for your answer.

Yes, using the Shell-VBA-function is also possible, but we do not want to have all the detailed path data of DOORS as Argument.

Meanwhile we force the user to manually start DOORS and login.

 

But we still have another Problem: Each time the function GetObject(, "DOORS.Application") crashes, even if DOORS has been started before.

Everytime I get the following VBA-error: "Laufzeitfehler '429': Objekterstellung durch Active-X-Komponente nicht möglich".

 

Used Doors Client Version: 9.6.1.9

Used Windows: Windows 7 Enterprise, Service Pack 1, 64-Bit

Used Excel Version for VBA-Code: Excel 2013

 

Does somebody have an idea, why this always Fails?

 

Regards,

Marco

Hmm ... 

First: how to know if DOORS is running ... 

The command 'tasklist /FO CSV" gives you the list of the processes runing.
Just parse the list to check if you find doors.exe.

I've done it once in DXL in order to prevent user to use 2 DOORS clients in the same time ... i can provide it as sample ... tell me if you need the split function ;)
 

Skip get_doors_processes() {
    string temp = tempFileName()
    command_system("tasklist /FO CSV > " temp "", 10 )
    Skip skp_rez = null
    Stream s_in = read temp
    string s_ligne; int index = 0
    string tmp 
    Regexp reg = regexp2("doors")
    Skip sk_tmp
    while ( true ) {
        s_in >> s_ligne
        if ( end s_in ) break
        tmp = s_ligne[0:10]""
        if ( tmp != "\"doors.exe\"" ) continue
        sk_tmp = split(s_ligne, ',')
        find(sk_tmp, 1, tmp)
        if (null skp_rez) skp_rez = create()
        put( skp_rez, index, tmp[1:length(tmp)-2]"")
        index = index + 1
        delete sk_tmp
    }
    close s_in
    deleteFile(temp)
    return skp_rez
}

 

(i let you see if it's running in the current session or not o;) )

 

If DOORS is running (in your session ...), just use the usual runFile feature ...

if DOORS is not running ... 

From VBA, you can create an empty temp file and use a .bat to launch DOORS executing a DXL that erase the empty file created by the VBA instance (-dxl option ... ). 
Then in VBA, just loop while the temp file exists. 

If the DXL has erased the file, then DOORS is lanched and you can go on ;)

I let you figure how add a timer security ...

Have fun !

 

)

Re: Starting DOORS from VBA does not wait until login
MarcoLuk - Wed Nov 22 03:24:31 EST 2017

pommCannelle - Fri Nov 17 05:18:51 EST 2017

Hmm ... 

First: how to know if DOORS is running ... 

The command 'tasklist /FO CSV" gives you the list of the processes runing.
Just parse the list to check if you find doors.exe.

I've done it once in DXL in order to prevent user to use 2 DOORS clients in the same time ... i can provide it as sample ... tell me if you need the split function ;)
 

Skip get_doors_processes() {
    string temp = tempFileName()
    command_system("tasklist /FO CSV > " temp "", 10 )
    Skip skp_rez = null
    Stream s_in = read temp
    string s_ligne; int index = 0
    string tmp 
    Regexp reg = regexp2("doors")
    Skip sk_tmp
    while ( true ) {
        s_in >> s_ligne
        if ( end s_in ) break
        tmp = s_ligne[0:10]""
        if ( tmp != "\"doors.exe\"" ) continue
        sk_tmp = split(s_ligne, ',')
        find(sk_tmp, 1, tmp)
        if (null skp_rez) skp_rez = create()
        put( skp_rez, index, tmp[1:length(tmp)-2]"")
        index = index + 1
        delete sk_tmp
    }
    close s_in
    deleteFile(temp)
    return skp_rez
}

 

(i let you see if it's running in the current session or not o;) )

 

If DOORS is running (in your session ...), just use the usual runFile feature ...

if DOORS is not running ... 

From VBA, you can create an empty temp file and use a .bat to launch DOORS executing a DXL that erase the empty file created by the VBA instance (-dxl option ... ). 
Then in VBA, just loop while the temp file exists. 

If the DXL has erased the file, then DOORS is lanched and you can go on ;)

I let you figure how add a timer security ...

Have fun !

 

)

Hello pommCannelle,

 

thank you very much for your sample code.

Until so far, I did not have time to try it.

Now I started my DOORS Client (but no Login) and I could see the process "doors.exe" in the Task process Manager of Windows.

So would your code this recognize? In that case, the recognizition would be too early for me.

 

Regards

Marco

Re: Starting DOORS from VBA does not wait until login
pommCannelle - Wed Nov 22 10:39:32 EST 2017

MarcoLuk - Wed Nov 22 03:24:31 EST 2017

Hello pommCannelle,

 

thank you very much for your sample code.

Until so far, I did not have time to try it.

Now I started my DOORS Client (but no Login) and I could see the process "doors.exe" in the Task process Manager of Windows.

So would your code this recognize? In that case, the recognizition would be too early for me.

 

Regards

Marco

Hmm... 

The idea was to use the result of the DOS command 'tasklist /FO CSV" BEFORE to launch DOORS, in order to know if you need to log and wait the effective start of DOORS or not. 

The sample was just to show a way to use the DOS command's result. You still need to do it in VB ... i'm pretty sure you can find how to do it in VB ;)

Re: Starting DOORS from VBA does not wait until login
pommCannelle - Thu Nov 23 06:06:27 EST 2017

MarcoLuk - Wed Nov 22 03:24:31 EST 2017

Hello pommCannelle,

 

thank you very much for your sample code.

Until so far, I did not have time to try it.

Now I started my DOORS Client (but no Login) and I could see the process "doors.exe" in the Task process Manager of Windows.

So would your code this recognize? In that case, the recognizition would be too early for me.

 

Regards

Marco

Hi :)

 

Here after a sample to check if DOORS is running in your VBA word.
Note that i use a sleep function because my system is a little bit slow and i need that my VBA lets some time to my DOS part.
It is just a sample, i do not check if you can read/write the files, i do not check if the doors process is runing in your session, i use a sleep insead of a file management to wait the DOS command end  ... 

 

So first of all, at the start of your VBA code :

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

and where you want in your VBA code ... 

Sub run_dxl(DXL As String)
    'GET THE PROCESS LIST
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim oFile As Object
    Set oFile = fso.CreateTextFile("D:\abatfile.bat", True)
    oFile.WriteLine "tasklist /FO CSV > ""D:\temp_processlist.txt"""
    oFile.Close
    Set oFile = fso.CreateTextFile("D:\temp_processlist.txt", True)
    oFile.Close
    Set fso = Nothing
    Set oFile = Nothing
    Shell ("D:\abatfile.bat")
    Sleep (100)
    ' READ THE PROCESS LIST
    Dim fileNo As Integer, process_list As String
    fileNo = FreeFile
    Open "D:\temp_processlist.txt" For Input As #fileNo
    process_list = Input$(LOF(fileNo), fileNo)
    Close #fileNo
    Sleep (100)
    Kill "D:\abatfile.bat"
    Kill "D:\temp_processlist.txt"
    ' TEST IF DOORS IS RUNING
    If (InStr(1, process_list, "doors.exe", vbBinaryCompare) = 0) Then
        'DOORS is not runing ... you need to open it properly
    End
    'NOW you can run your DXL
End Sub

I use to deal with some dedicated temp files in my projects ... easier for debug purpose.
But you can use real temp files instead of my 'abatfile.bat' and 'temp_processlist.txt' ;)

Have fun !

Re: Starting DOORS from VBA does not wait until login
MarcoLuk - Thu Nov 23 06:27:09 EST 2017

pommCannelle - Thu Nov 23 06:06:27 EST 2017

Hi :)

 

Here after a sample to check if DOORS is running in your VBA word.
Note that i use a sleep function because my system is a little bit slow and i need that my VBA lets some time to my DOS part.
It is just a sample, i do not check if you can read/write the files, i do not check if the doors process is runing in your session, i use a sleep insead of a file management to wait the DOS command end  ... 

 

So first of all, at the start of your VBA code :

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

and where you want in your VBA code ... 

Sub run_dxl(DXL As String)
    'GET THE PROCESS LIST
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Dim oFile As Object
    Set oFile = fso.CreateTextFile("D:\abatfile.bat", True)
    oFile.WriteLine "tasklist /FO CSV > ""D:\temp_processlist.txt"""
    oFile.Close
    Set oFile = fso.CreateTextFile("D:\temp_processlist.txt", True)
    oFile.Close
    Set fso = Nothing
    Set oFile = Nothing
    Shell ("D:\abatfile.bat")
    Sleep (100)
    ' READ THE PROCESS LIST
    Dim fileNo As Integer, process_list As String
    fileNo = FreeFile
    Open "D:\temp_processlist.txt" For Input As #fileNo
    process_list = Input$(LOF(fileNo), fileNo)
    Close #fileNo
    Sleep (100)
    Kill "D:\abatfile.bat"
    Kill "D:\temp_processlist.txt"
    ' TEST IF DOORS IS RUNING
    If (InStr(1, process_list, "doors.exe", vbBinaryCompare) = 0) Then
        'DOORS is not runing ... you need to open it properly
    End
    'NOW you can run your DXL
End Sub

I use to deal with some dedicated temp files in my projects ... easier for debug purpose.
But you can use real temp files instead of my 'abatfile.bat' and 'temp_processlist.txt' ;)

Have fun !

Thank you very much again!

 

Meanwhile I could fix a general problem with my local doors client installation on my computer.

I deinstalled and reinstalled the Client again, so that the COM mechanism ("Doors.Application") is working better.

So with the command Set DoorsObj = GetObject("", "Doors.Application") I can obtain the running DOORS instance.

The only wrong behaviour is if Doors is not running, in that case it starts Doors until the login prompt but does

asynchronically continues VBA code execution with a failure.

 

I will try to test your code.

 

Marco